﻿namespace ACCOUNTING.LVY.Business
{
    using ACCOUNTING;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Data;
    using System.Windows.Forms;

    public class clsDoiTuongTHCPChiTiet
    {
        private string mKhoa = "";
        private string mKhoaDoiTuongTapHopChiPhi="";
        private string mKhoaHangHoa = "";
        private string mTenHangHoa="";
        private string mDienGiai="";
        public bool Load(string pKhoa)
        {
            bool flag=false;
            try
            {
                string commandText = "SELECT * FROM DM_DoiTuongTapHopChiPhiChiTiet WHERE Khoa = '" + pKhoa + "'";
                IDataReader dataReader = DBHelper.ExecuteReader(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
                if (dataReader.Read())
                {
                    this.mKhoa = Conversions.ToString(modGeneral.GetValue(dataReader, 0, modGeneral.typeOfColumn.GetString));
                    this.mKhoaDoiTuongTapHopChiPhi = Conversions.ToString(modGeneral.GetValue(dataReader, 1, modGeneral.typeOfColumn.GetString));
                    this.mKhoaHangHoa = Conversions.ToString(modGeneral.GetValue(dataReader, 2, modGeneral.typeOfColumn.GetString));
                    this.mTenHangHoa = Conversions.ToString(modGeneral.GetValue(dataReader, 3, modGeneral.typeOfColumn.GetString));
                    this.mDienGiai = Conversions.ToString(modGeneral.GetValue(dataReader, 4, modGeneral.typeOfColumn.GetString));                   
                }
                dataReader.Close();
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool Save()
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[5];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, this.mKhoa);
                commandParameters[1] = DBHelper.createParameter("@KhoaDoiTuongTHCP", DbType.Int64, ParameterDirection.Input, this.mKhoaDoiTuongTapHopChiPhi);
                commandParameters[2] = DBHelper.createParameter("@KhoaHangHoa", DbType.Int64, ParameterDirection.Input, this.mKhoaHangHoa);
                commandParameters[3] = DBHelper.createParameter("@TenHangHoa", DbType.Int64, ParameterDirection.Input, this.mTenHangHoa);
                commandParameters[4] = DBHelper.createParameter("@DienGiai", DbType.Int64, ParameterDirection.Input, this.mDienGiai);
                if (DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "ST_sp_DoiTuongTapHopChiPhiChiTiet", commandParameters) > 0)
                {
                    return true;
                }
                flag = false;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public string Khoa
        {
            get
            {
                return this.mKhoa;
            }
            set
            {
                this.mKhoa = value;
            }
        }
        public string KhoaDoiTuongTHCP
        {
            get
            {
                return this.mKhoaDoiTuongTapHopChiPhi;
            }
            set
            {
                this.mKhoaDoiTuongTapHopChiPhi = value;
            }
        }
        public string KhoaHangHoa
        {
            get
            {
                return this.mKhoaHangHoa;
            }
            set
            {
                this.mKhoaHangHoa = value;
            }
        }
        public string TenHangHoa
        {
            get
            {
                return this.mTenHangHoa;
            }
            set
            {
                this.mTenHangHoa = value;
            }
        }
        public string DienGiai
        {
            get
            {
                return this.mDienGiai;
            }
            set
            {
                this.mDienGiai = value;
            }
        }

        
    }
}

